home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / ISAPIEXT.PAK / ISAPISTR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.5 KB  |  109 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1997 by Borland International, All Rights Reserved
  4. // written by Michael Sawczyn
  5. //----------------------------------------------------------------------------
  6. #ifndef TIsapiStream_H
  7. #define TIsapiStream_H
  8.  
  9. class TIsapiExtension;
  10.  
  11. #include <iostream.h>
  12.  
  13. //
  14. // Proxy for server output. Data can be streamed to this object, and
  15. // will be written to the server.
  16. //
  17.  
  18. class TIsapiStreambuf : public streambuf
  19.     {
  20.     static uint bufsize;
  21.  public:
  22.     TIsapiStreambuf( TIsapiExtension * aParent )
  23.         {
  24.         Parent = aParent;
  25.  
  26.         isapibuf = new char[bufsize];
  27.                 memset( isapibuf, 0, bufsize );
  28.                 setbuf( isapibuf, bufsize-1, 1 );
  29.                 setp( isapibuf, isapibuf + (bufsize-1) );
  30.         }
  31.  
  32.     ~TIsapiStreambuf(  )
  33.         {
  34.         // delete[] isapibuf;
  35.         }
  36.  
  37.     void    SetParent( TIsapiExtension * aParent )
  38.         {
  39.         Parent = aParent;
  40.         }
  41.  
  42.     virtual int overflow( int );
  43.     virtual int sync(  );
  44.  
  45. protected:
  46. private:
  47.     // Informs the stream of the parent TIsapiExtension.
  48.     //
  49.     TIsapiStreambuf( const TIsapiStreambuf & )
  50.         {
  51.  
  52.         }
  53.  
  54.     TIsapiStreambuf & operator = ( const TIsapiStreambuf & )
  55.         {
  56.         return *this;
  57.         }
  58.  
  59.     /**# :[Label = "Parent"] [Cardinalities = "0..1/"] */
  60.     TIsapiExtension *Parent;
  61.     char   *isapibuf;
  62.     };
  63.  
  64. class TIsapiStream : public ostream
  65.     {
  66.     friend class TIsapiExtension;
  67.  public:
  68.             TIsapiStream( TIsapiExtension * parent )
  69.         {
  70.         bp = new TIsapiStreambuf( parent );
  71.         ios::init( bp );
  72.         }
  73.  
  74.     virtual ~TIsapiStream(  )
  75.         {
  76.         sync(  );
  77.         delete  bp;
  78.                 bp = NULL;
  79.         }
  80.  
  81.     int     sync(  )
  82.         {
  83.         return bp->sync(  );
  84.         }
  85.  
  86.  protected:
  87.  private:
  88.     // Informs the stream of the parent TIsapiExtension.
  89.     //
  90.     void    SetParent( TIsapiExtension * parent )
  91.         {
  92.         dynamic_cast < TIsapiStreambuf * >( bp )->SetParent( parent );
  93.         }
  94.  
  95.     // Private default constructor to prevent accidental creation.
  96.     //
  97.     TIsapiStream(  );
  98.  
  99.     // Private to prevent accidental copying.
  100.     //
  101.     TIsapiStream( const TIsapiStream & );
  102.  
  103.     // Private to prevent accidental copying.
  104.     //
  105.     TIsapiStream & operator = ( const TIsapiStream & );
  106.     };
  107.  
  108. #endif
  109.